package com.hardydou.system.service.impl;

import com.hardydou.system.mapper.SystemConfigMapper;
import com.hardydou.system.model.SystemConfig;
import com.hardydou.system.service.ISystemConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author ：hardy
 * @description：系统参数
 * @date ：Created in 2020/6/13
 * @Copyright ：Hardydou.com
 */
@Service
public class SystemConfigServiceImpl implements ISystemConfigService {

    @Autowired
    SystemConfigMapper configMapper;

    @Override
    public int add(SystemConfig config) {
        config.setCtime(new Date());
        config.setUtime(config.getCtime());
        return configMapper.insert(config);
    }

    @Override
    public int update(SystemConfig config) {
        return configMapper.updateByPrimaryKeySelective(config);
    }

    @Override
    public int deleteById(Long configId) {
        return configMapper.deleteByPrimaryKey(configId);
    }

    @Override
    public SystemConfig findById(Long configId) {
        return configMapper.selectByPrimaryKey(configId);
    }

    @Override
    public SystemConfig findByConfigKey(String key) {
        return configMapper.findByConfigKey(key);
    }

    @Override
    public List<SystemConfig> list(Map params) {
        return configMapper.list(params);
    }
}
